package kr.hkit.summary_java.erp;

import java.sql.Connection;
import java.sql.SQLException;
import java.util.ArrayList;

import kr.hkit.myframework.db.ConnectionFactory;
import kr.hkit.myframework.db.DBProperies;
import kr.hkit.myframework.db.DbUtil;
import kr.hkit.summary_java.erp.dao.DaoInterface;
import kr.hkit.summary_java.erp.dao.DepartmentDAO;
import kr.hkit.summary_java.erp.dto.Department;

public class TestMain {

	public static void main(String[] args) throws SQLException {
		String filePath = "dbcon.xml";
		// String driver = "com.mysql.jdbc.Driver";
		// String url = "jdbc:mysql://localhost:3306/erp";
		// String user = "root";
		// String password = "1111";
		//
		// DBProperies.savePropertis("dbcon.xml", driver, url, user, password);
		DBProperies.prnProperties(DBProperies.loadPropertis(filePath));

		Connection con = ConnectionFactory.getConnection();

		DaoInterface<Department> dao = new DepartmentDAO(con);

//		dao.insertItem(new Department(7, "디자인", 11));
//		dao.updateItembyNo(new Department(7, "디자인", 15));
//		dao.deleteItembyNo(new Department(7, "디자인", 15));
		Department dept = new Department();
		dept.setDeptNo(1);
		Department temp = dao.searchItem(dept);
		System.out.println(temp);
		
		ArrayList<Department> lists = dao.listItems();

		for (Department d : lists) {
			System.out.println(d);
		}

		DbUtil.close(con);
	}
}
